﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace GameEngine
{
    class Menue
    {
        private List<Button> _Buttons; //Buttons mit den Optionen
        private string _Titel; //Titel, der zentriert über den Buttons Steht
        private Vector2 _TitePosition; //Ort des Titels
        private SpriteFont _Schriftart;
        private bool _Aktiv = false;

        #region Konstruktoren
        public Menue()
        {
            _Buttons = new List<Button>();
        }

        public Menue(string Titel, Vector2 TitelPositiond)
        {
            _Titel = Titel;
            _TitePosition = TitelPosition;
            _Buttons = new List<Button>();
        }

        #endregion

        public List<Button> GetButton()
        {
            return _Buttons;
        }

        public void AddButton(Button Add, Int32 ID)
        {
            _Buttons.Add(new Button());
            _Buttons[ID] = new Button();
            _Buttons[ID].Position = Add.Position;
            _Buttons[ID].Schriftart = Add.Schriftart;
            _Buttons[ID].SchriftPosition = Add.SchriftPosition;
            _Buttons[ID].Text = Add.Text;
            _Buttons[ID].Texture = Add.Texture;
            _Buttons[ID].TextureAktiv = Add.TextureAktiv;
        }

        public string Titel
        {
            get { return _Titel; }
            set { _Titel = value; }
        }

        public Vector2 TitelPosition
        {
            get { return _TitePosition; }
            set { _TitePosition = value; }
        }

        public SpriteFont Schriftart
        {
            get { return _Schriftart; }
            set { _Schriftart = value; }
        }

        public bool Aktiv
        {
            get { return _Aktiv; }
            set { _Aktiv = value; }
        }

        public void Draw(SpriteBatch sb)
        {
            sb.Begin();

                sb.DrawString(this._Schriftart, this._Titel, this._TitePosition, Color.White);



                try
                {
                    for (int i = 0; i < _Buttons.Count; i++)
                    {
                        _Buttons[i].Draw(sb);
                    }
                }
                catch
                { }

                sb.End();
            
        }

        public bool IstButtonAktiv(int ID)
        {
            try
            {
                return _Buttons[ID].IsActive();
            }
            catch
            {
                return false;
            }
        }
    }
}
